package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

public class HWBJJ15 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] nums = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int l = 0;
        int r = 0;

        int index = 0;
        while (index <  10) {
            int a = nums[index++];
            int b = nums[index++];
            if (Math.abs(l+a -r-b) < Math.abs(l+b -r-a)) {
                l +=a;
                r +=b;
            } else {
                l+=b;
                r+=a;
            }
        }
        System.out.println(Math.abs(l-r));
    }
}
